<?php

namespace IDock\Insurance\HBIC\Response;

use IDock\Http\Response;
use IDock\Printer\UploadFilePrinter;

class UploadFileResponse extends AllHBICResponse
{

    public function resolve(): Response
    {
        $body = $this->getBody();
        $data = json_decode($body,true);
        $this->setBody($data);
        return $this;
    }

    public function printerInit(): Response
    {
        $uploadFilePrinter = new UploadFilePrinter();

        $this->printer = $uploadFilePrinter;

        $data = $this->getBody();
        if(($data['resultcode'] ?? '') != 1){
            $this->setError('上传文件失败');
        }

        return $this;
    }
}
